encode country, gen (id)
drop country
rename id country
xtset country year_n

tab rulingpartyideology, gen (ruling)
rename ruling6 left

gen ln_realgdppercapita = ln(realgdppercapita)

gen corruption = 1- factor2absenceofcorruption
gen bureaucrat_corruption = 1 - governmentofficialsintheexecutiv
gen legislature_corruption = 1 - governmentofficialsinthelegislat
gen judicial_corruption = 1 - governmentofficialsinthejudicial
gen police_military_corruption = 1 - governmentofficialsinthepolicean
gen civil_corruption = 1 - civiljusticeisfreeofcorruption
gen criminal_corruption = 1 - criminalsystemisfreeofcorruption
gen civil_conflict = 1 - civilconflictiseffectivelylimite

recode imf (missing = 0)
recode worldbank (missing = 0)

tab year_n, gen (yeardummy)

//H1
xtreg factor4fundamentalrights corruption civil_conflict left military ln_realgdppercapita trade fdiinflow imf worldbank yeardummy1 yeardummy2 yeardummy3 yeardummy4 yeardummy5 yeardummy6 yeardummy7 yeardummy8 yeardummy9 yeardummy10, fe
xtreg factor4fundamentalrights legislature_corruption judicial_corruption bureaucrat_corruption police_military_corruption civil_conflict left military ln_realgdppercapita trade fdiinflow imf worldbank yeardummy1 yeardummy2 yeardummy3 yeardummy4 yeardummy5 yeardummy6 yeardummy7 yeardummy8 yeardummy9 yeardummy10, fe
gen sam1 = e(sample)

//Labor Rights
xtreg fundamentallaborrightsareeffecti corruption civil_conflict left military ln_realgdppercapita trade fdiinflow imf worldbank yeardummy1 yeardummy2 yeardummy3 yeardummy4 yeardummy5 yeardummy6 yeardummy7 yeardummy8 yeardummy9 yeardummy10, fe
xtreg fundamentallaborrightsareeffecti legislature_corruption judicial_corruption bureaucrat_corruption police_military_corruption civil_conflict left military ln_realgdppercapita trade fdiinflow imf worldbank yeardummy1 yeardummy2 yeardummy3 yeardummy4 yeardummy5 yeardummy6 yeardummy7 yeardummy8 yeardummy9 yeardummy10, fe

// Freedom of Association
xtreg freedomofassemblyandassociationi corruption civil_conflict left military ln_realgdppercapita trade fdiinflow imf worldbank yeardummy1 yeardummy2 yeardummy3 yeardummy4 yeardummy5 yeardummy6 yeardummy7 yeardummy8 yeardummy9 yeardummy10, fe 
xtreg freedomofassemblyandassociationi legislature_corruption judicial_corruption bureaucrat_corruption police_military_corruption civil_conflict left military ln_realgdppercapita trade fdiinflow imf worldbank yeardummy1 yeardummy2 yeardummy3 yeardummy4 yeardummy5 yeardummy6 yeardummy7 yeardummy8 yeardummy9 yeardummy10, fe

// Descriptive Statistics
sum factor4fundamentalrights freedomofassemblyandassociationi freedomofopinionandexpressionise fundamentallaborrightsareeffecti corruption factor3opengovernment civil_conflict left realgdppercapita trade fdiinflow military imf worldbank if sam1==1

pwcorr factor4fundamentalrights freedomofassemblyandassociationi freedomofopinionandexpressionise fundamentallaborrightsareeffecti corruption factor3opengovernment civicparticipation civilconflictiseffectivelylimite left ln_realgdppercapita trade fdiinflow military imf worldbank if sam1==1, star(.001)
